package com.le.tester.book.concurrentjavafight.l10_1_1;

/**
 * createTime：2023/1/2 15:09
 * description：简单的顺序死锁，不能这么做
 */
public class LeftRightDeadLock {

    private final Object left = new Object();
    private final Object right = new Object();

    public void leftRight() {
        synchronized (left) {
            synchronized (right) {
                System.out.println("leftRight");
            }
        }
    }

    public void rightLeft() {
        synchronized (right) {
            synchronized (left) {
                System.out.println("rightLeft");
            }
        }
    }
}

